home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-23 | 3.7 KB | 85 lines | [TEXT/ttxt] |
-
- CopyBits Demo.p
-
- Implemented in Oct 1995 using Metrowerks CW6.
- Converted from C code written in May 1995 using
- Metrowerks CodeWarrior v5.
-
- This Pascal CopyBits Demo project v3.1P is by Bill Catambay.
- The orginal C CopyBits Demo project v3.1 was by Kenneth Worley.
-
- This code is Copyright 1995. All Rights Reserved.
- You may use this code in any project of your own. You may also
- redistribute this project to anyone else as long as 1) all the
- project files (including documentation files) are kept together,
- and 2) nothing is charged for the project.
-
- I really don't know what the rules are for C code converted to
- Pascal as far as permission, licensing, and all that garbage.
- If you have any information to shed light on this subject for me,
- please E-mail me at Catambay@aol.com (and I thank you in advance).
-
- Worley notes:
- This is a tutorial project that demonstrates the use of
- CopyBits and offscreen Graphics Worlds (GWorlds). It shows
- several instances of copying images to and from offscreen
- graphics worlds using CopyBits, provides several macros that
- make the process a little easier, shows an example of
- drawing into an offscreen graphics world and how that can
- improve onscreen animation, and it demonstrates a "fade"
- using CopyBits to fade a portion of the screen to black.
-
- In a nutshell, the app puts up a dialog that shows two
- "source" pictures (1 & 2) and a destination area. Clicking
- on the "Copy" buttons above each of the source pictures
- causes the picture to be copied to the destination area.
- Picture 1 is labelled as "flickery animation" and picture 2
- is labelled as "smooth animation." When you put the cursor
- over each picture, you should see a difference in how a
- colored circle is animated over the picture. You should
- occasionally see the background "flicker" through on
- picture 1, but not on picture 2 because it uses an
- intermediary GWorld to draw in.
-
- The Fade to black button over the destination area will
- cause that area to fade to black from whatever happens to
- be in there. It does this by repeatedly copying a gray
- rectangle from a GWorld into the destination area using
- the subPin transfer mode of CopyBits. The erase button
- erases the destination area.
-
- The Fade picture buttons cause the picture under the
- button to be faded into whatever is currently in the
- destination area. This is accomplished using CopyBits'
- blend transfer mode.
-
- Conversion notes:
- Of course, all the standard C to Pascal translation stuff
- applies. Additionally, there are some pointer stuff I had to
- tweak to get this working in Pascal. I also had to play with
- the RGBColor records sometimes, because in Pascal they are treated
- as integers, but in C they are treated as unsigned (I'm talking
- about the components of course).
-
- Here's as example of C to Pascal translation which fuels my love for Pascal:
-
- As originally done in C:
- LocalToGlobal(* (Point*) &(offscreenRect.top));
- LocalToGlobal(* (Point*) &(offscreenRect.bottom));
-
- As translated into Pascal:
- LocalToGlobal(offscreenRect.topleft);
- LocalToGlobal(offscreenRect.botRight);
-
- Got rid of most of the C macros, converting just one of them, WinBitMap,
- into a pascal function. Also converted to pascal are three other
- C libraries. They have been implemented as UNITs: MyAlerts, MyDialogUtils,
- and MySystemUtils. And there was some other stuff I had to do to get
- this working, but I'm too tired now to try and remember it all. Just enjoy
- the code, and I hope you learn lots of stuff!
-
- Questions? Comments? Praise? Criticism? Jobs? If it has
- to do with the Pascal code included here, write to
- Bill Catambay at catambay@aol.com, and if it has to do with
- the original C code, write to Kenneth Worley at KNEworley@aol.com.
-